<%--
  Created by IntelliJ IDEA.
  User: 余先生
  Date: 2021/6/7
  Time: 17:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="../js/jquery-3.4.1.min.js" language="JavaScript"></script>
    <script language="JavaScript">
        $(function () {
            $.get("/getGrade",null,function (www) {
                for (var i=0;i<www.length;i++){
                    var option=$("<option  value="+www[i].gid+">"+www[i].gname+"</option>");
                    $("#gid").append(option);
                }
                $("#gid").val(${stu.gid})
                <%--$($("#gid").find("option")[${stu.gid}-1]).attr("selected",true);--%>
            },"json");
        });
    </script>

</head>
<body>
修改学生
<form id="form1" name="form1" method="post" action="/updStudent">
    <p>学号:
        <input type="text" readonly="readonly" name="xh" id="ss" value="${stu.xh}" />
    </p>
    <p>姓名:
        <input type="text" name="name" id="textfield" value="${stu.name}" />
    </p>
    <p>年龄:
        <input type="text" name="age" id="textfield2" value="${stu.age}" />
    </p>
    <p>性别:
        <input name="sex" type="radio" id="radio" value="男" ${stu.sex=="男"?"checked":""} />
        男
        <input type="radio" name="sex" id="radio2" value="女"${stu.sex=="女"?"checked":""} />
        女
    </p>
    <p>生日:
        <fmt:formatDate value="${stu.birthday}" pattern="yyyy-MM-dd" var="day"></fmt:formatDate>
        <input type="date" name="birthday" value="${day}">
    </p>
    <p>地址:
        <input type="text" name="address" id="textfield4" value="${stu.address}" />
    </p>
    <p>状态:
        <input type="text" name="state" id="textfield5" value="${stu.state}" />
    </p>
    <p>年级:
        <%--<input type="text" name="gid" id="textfield6" value="${stu.gid}" />--%>
        <select id="gid" name="gid" >
        </select>

        下拉列表，从数据库中查询年级
    </p>
    <p>
        <input type="submit" name="button" id="button" value="提交" />
    </p>
</form>
</body>
</html>

